import java.util.Scanner;

/*
    Z字形变换
 */
public class Z {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int numRows = sc.nextInt();
        if(numRows == 1) System.out.println(s);;
        int len = s.length();
        int cycle = 2 * numRows -2;
        StringBuilder sBuffer = new StringBuilder(len);
        for (int i = 0; i < numRows; i++) {
            for (int j = 0; j < len; j++) {
                if (j % cycle == i || j % cycle == (cycle - i)) {
                    sBuffer.append(s.charAt(j));
                }
            }
        }
        System.out.println(sBuffer.toString());
    }
}
